﻿using System;
using Microsoft.SharePoint;

namespace ServBus.ListForm2010.License
{
    internal enum ActivationType
    {
        Activated,
        Failed,
        Waiting
    }

    [Serializable]
    internal class ActivationInfo : IComparable<ActivationInfo>
    {
        public Guid SiteId { get; private set; }
        public Guid WebId { get; private set; }
        public DateTime ActivatedTime { get; private set; }
        public ActivationType Type { get; internal set; }
        public bool IsValid
        {
            get { return this.Type != ActivationType.Failed; }
        }

        public ActivationInfo(SPSite site, SPWeb web)
        {
            this.SiteId = site.ID;
            this.WebId = web.ID;
            this.ActivatedTime = DateTime.Now;
            this.Type = ActivationType.Waiting;
        }

        #region IComparable<ActivationInfo> 成员

        public int CompareTo(ActivationInfo other)
        {
            if (other == null)
                return -1;
            return this.ActivatedTime.CompareTo(other.ActivatedTime);
        }

        #endregion
    }
}
